<template>
  <div
    class="bg-#e5e5e5 p-1.25rem box-border bg-[url('@/assets/images/home-bg.jpg')] object-center"
  >
    <div class="w-60% m-auto shadow-2xl">
      <MdViewer :content="post.content" />
    </div>
  </div>
</template>

<script setup lang="ts">
//@ts-ignore
import MdViewer from '@/components/MdViewer/index.vue'
//@ts-ignore
import { PostControllerService, type PostVO } from '@/servers'
//@ts-ignore
import { ResponseCode } from '@/servers/core/request'
import { onMounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const content = ref('')
const route = useRoute()
const router = useRouter()
const post: PostVO = reactive({})
onMounted(async () => {
  if (!route.params?.id) {
    router.back()
  } else {
    const res = await PostControllerService.getPostVoByIdUsingGet(route.params.id as any)
    if (res.code == ResponseCode.SUCCESS) {
      Object.assign(post, res.data)
    }
  }
})
</script>
